layui.use(['form','layer','jquery'],function(){
    var form = layui.form,
        layer =layui.layer,
        $ = layui.jquery;

    $(".loginBody .seraph").click(function(){
        layer.msg("这只是做个样式，至于功能，你见过哪个后台能这样登录的？还是老老实实的找管理员去注册吧",{
            time:5000
        });
    })

    form.on("submit(formRegister)",function(data) {
        $(this).text("注册中...").attr("disabled","disabled").addClass("layui-disabled");
        $.ajax({
            type : 'post',
            url  : '/first/doRegister',
            async: false,
            data : {
                "nickName":data.field.nickName,
                "password":data.field.password,
                "name"    :data.field.name,
                "address" :data.field.address,
                "isOn"    :data.field.isOn,
                "email"   :data.field.email,
                "phone"   :data.field.phone,
                "desc"    :data.field.desc
            },
            dataType: 'json',
            success: function(result){
                alert('register SUCCESS'+result["account"]);
                window.location.href='index.html';
            },
            error: function (result) {
                alert('register error');
            }
        });
    })
})

function register() {
    window.location.href="success.html";
}


